package com.yanqu.road.server.cmd.cross.marriage;

import com.yanqu.road.pb.marriage.CrossMarriageProto;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.command.Command;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.manger.marriage.MarriageMgr;
import com.yanqu.road.server.manger.player.GamePlayerMgr;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.Protocol;
import io.netty.channel.ChannelHandlerContext;


@Cmd(code = Protocol.S_CROSS_MARRIAGE_PUBLISH_RESP, desc = "跨服联姻发布响应")
public class CrossMarriagePublishRespCmd implements Command {
	@Override
	public void execute(ChannelHandlerContext ctx, YanQuMessage packet) throws Exception {
		CrossMarriageProto.CrossMarriageApplyPublishCrossRespMsg reqMsg = CrossMarriageProto.CrossMarriageApplyPublishCrossRespMsg.parseFrom(packet.getBytes());
		GamePlayer player = GamePlayerMgr.getPlayer(packet.getPlayerId());
		if(null != player) {
			int ret = MarriageMgr.crossMarriagePublishResponse(player, reqMsg);
			CrossMarriageProto.CrossMarriageApplyPublishRespMsg.Builder respMsg = CrossMarriageProto.CrossMarriageApplyPublishRespMsg.newBuilder();
			respMsg.setRet(ret);
			player.sendPacket(Protocol.U_CROSS_MARRIAGE_APPLY_PUBLISH, respMsg);
		}
	}
}
